FROM nginx:1.16-alpine

ARG X_GID
ARG X_UID

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories\
	&& apk update \
    && apk add -U tzdata \
	&& cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
    && apk del tzdata \
    && rm -rf /var/cache/apk/* \
    && rm -rf /root/.cache \
    && rm -rf /tmp/* \
    && set -eux; \
#    if [ -z "`getent group 2001`" ]; then \
#        addgroup --system --gid 2001 clonetrooper; \
#    fi; \
#    adduser --system --disabled-password --uid 2001 clonetrooper
    if [ -z "`getent group ${X_GID}`" ]; then \
        addgroup -S -g ${X_GID} clonetrooper; \
    fi && \
    adduser -S -D -u ${X_UID} -G `getent group ${X_GID} | cut -d: -f1` clonetrooper

COPY ./conf.d/ /etc/nginx/conf.d/
COPY ./nginx.conf /etc/nginx/
#COPY ./secrets/id_rsa /run/secrets/dx/deploy
#COPY  --from=php_yjs:latest /data/www/yjs/ /data/www/yjs/
#COPY ./code_conf /data/www/yjs/common/config/
#RUN { \
#        echo 'Host dx.wangcaigu.cn'; \
#        echo '    Hostname dx.wangcaigu.cn'; \
#        echo '    IdentityFile /run/secrets/dx/deploy'; \
#        echo '    IPQoS throughput'; \
#    } | tee /etc/ssh/ssh_config 
#RUN chmod 0600 /run/secrets/dx/deploy \
#    && mkdir -p -m 0700 /root/.ssh \
#    && mkdir -p /data/www/yjs \
#    && chown -R nginx:nginx /data/www/yjs
WORKDIR /data/www/yjs
#RUN ssh-keyscan dx.wangcaigu.cn >> /root/.ssh/known_hosts && \
#    git clone -b master ssh://vcs@dx.wangcaigu.cn/source/yjs.git  yjs && \
#	chown -R nginx:nginx /data
EXPOSE 80
